package codingforgreat.class15;

public class Class02_LC_122 {
    public int maxProfit(int[] prices) {
        int ans  = 0;
        int res = 0;
        for (int i = 1; i < prices.length; i++) {
            res = Math.max(0,prices[i] - prices[i-1]);
            ans += res;
        }
        return ans;
    }
}
